package leetcode_二叉树;

import general_class.TreeNode;

/**
 * 二叉树展开为链表
 * 算法：深度优先搜索
 *
 * @author yezh
 * @date 2024/1/21 18:52
 */
public class _114 {

    TreeNode tmp = new TreeNode();

    public void flatten(TreeNode root) {
        if (root == null) return;
        tmp.right = root;
        TreeNode left = root.left, right = root.right;
        root.left = null;
        root.right = null;
        tmp = tmp.right;
        flatten(left);
        flatten(right);
    }

}
